<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserCouponTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //用户优惠券
        Schema::create('user_coupon', function(Blueprint $table) {
            $table->bigIncrements('id')->comment('自增id');
            $table->integer('user_id')->comment('用户标识');
            $table->integer('coupon_id')->default(0)->comment('优惠券id');
            $table->string('name')->nullable()->comment('优惠券名称');
            $table->decimal('money')->default(0)->comment('优惠券金额');
            $table->string('type')->nullable()->comment('优惠券类型 direct 直接优惠/satisfy 满金额优惠');
            $table->integer('satisfy_money')->default(0)->comment('满足优惠需要的金额');
            $table->timestamp('start_time')->nullable()->comment('开始时间');
            $table->timestamp('end_time')->nullable()->comment('结束时间');
            $table->integer('is_use')->default(0)->comment('是否使用 0：未使用1：已使用');
            $table->integer('is_locking')->default(0)->comment('是否锁定 0：不锁定 1：已锁定');
            $table->bigInteger('img_id')->default(0)->comment('图片');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_coupon');
    }
}
